﻿using System;
using System.Data;
using System.Collections;
using System.Configuration;
using System.Web;
using System.Web.Security;

using XinBang.Entity;

namespace XinBang.Util
{
    /// <summary>
    /// 用于读、写、删除、比较Session中的用户信息。
    /// </summary>
    public class SessionUtil
    {
        private SessionUtil() { }
        /// <summary>
        /// 保存会员Session
        /// </summary>
        /// <param name="mm"></param>
        public static void SaveMemberSession(Member mm)
        {
            System.Web.HttpContext.Current.Session["Mem"] = mm;
        }
        /// <summary>
        /// 获取会员Session
        /// </summary>
        /// <returns>会员对象</returns>
        public static Member GetMemberSession()
        {
            object o = System.Web.HttpContext.Current.Session["Mem"];
            if (o == null) throw new MissSessionException("读取MemberSession失败。");
            else return (o as Member);
        }
        /// <summary>
        /// 移除会员Session
        /// </summary>
        public static void RemoveMemberSession()
        {
            object o = System.Web.HttpContext.Current.Session["Mem"];
            if (o != null) System.Web.HttpContext.Current.Session.Remove("Mem");
        }

    }
}